﻿using System;
using System.Windows.Input;
using System.Windows.Threading;
using WpfHeadtracking;

namespace WpfHeadtrackingTest
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1
    {
        public Window1()
        {
            InitializeComponent();
            var p = (MouseHeadtrackingProvider)FindResource("mouseHtProvider");
            p.TrackingArea = this;

            KeyDown += Window1_KeyDown;
            var t = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(20) };
            t.Tick += t_Tick;
            t.Start();
        }

        void t_Tick(object sender, EventArgs e)
        {
            var htp = ht3dd.HeadtrackingProvider;

            headXLbl.Content = htp.HeadPosition.X;
            headYLbl.Content = htp.HeadPosition.Y;
            headDistLbl.Content = htp.HeadPosition.Z;
            isHeadtracking.Content = htp.IsHeadtracking;
        }

        void Window1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Space)
            {
                ht3dd.ResetCameraCenter();
            }
        }
    }
}
